home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-02 / vgaintro.zip / AA.PAS < prev    next >
Pascal/Delphi Source File  |  1991-07-30  |  5KB  |  220 lines

  1. Program PaletteTricks;
  2.  
  3.   Uses Crt;
  4.  
  5.  
  6.   Const CGA_CharSet_Seg = $0F000;
  7.         CGA_CharSet_Ofs = $0FA6E;
  8.         CharLength      = 8;
  9.         NumChars        = 256;
  10.         VGA_Segment     = $0A000;
  11.         NumCycles       = 200;
  12.         Radius          = 80;
  13.  
  14.         DispStr         : String =
  15. '...LOADER BY FRED NIETZCHE     CALL CENTERPOINT! (301) 309-0144, 9600+ ONLY  NUP: TERMINEX'+
  16. '           WHATEVER ELSE YOU WANT HERE...                         ';
  17.  
  18.         Colors : Array[1..15*3] Of Byte =
  19.                  (  7,  7, 63,
  20.                    15, 15, 63,
  21.                    23, 23, 63,
  22.                    31, 31, 63,
  23.                    39, 39, 63,
  24.                    47, 47, 63,
  25.                    55, 55, 63,
  26.                    63, 63, 63,
  27.                    55, 55, 63,
  28.                    47, 47, 63,
  29.                    39, 39, 63,
  30.                    31, 31, 63,
  31.                    23, 23, 63,
  32.                    15, 15, 63,
  33.                     7,  7, 63  );
  34.  
  35.  
  36. Type  OneChar =Array[1..CharLength] Of Byte;
  37.  
  38.  
  39. Var   CharSet : Array[1..NumChars] Of OneChar;
  40.       Locs    : Array[1..NumCycles] Of Integer;
  41.       BarLocs : Array[1..4] Of Integer;
  42.  
  43.  
  44.   Procedure GetChars;
  45.  
  46.     Var NumCounter,
  47.         ByteCounter,
  48.         MemCounter   :Integer;
  49.   
  50.     Begin { GetChars }
  51.       MemCounter:=0;
  52.       For NumCounter:=1 To NumChars Do
  53.         For ByteCounter:=1 To CharLength Do
  54.           Begin
  55.             CharSet[NumCounter][ByteCounter]:=Mem[CGA_CharSet_Seg:CGA_CharSet_Ofs+MemCounter];
  56.             Inc(MemCounter);
  57.           End;
  58.     End;  { GetChars }
  59.  
  60.  
  61.   Procedure VideoMode ( Mode : Byte );
  62.  
  63.     Begin { VideoMode }
  64.       Asm
  65.         Mov  AH,00
  66.         Mov  AL,Mode
  67.         Int  10h
  68.       End;
  69.     End;  { VideoMode }
  70.  
  71.  
  72.   Procedure SetColor ( Color, Red, Green, Blue : Byte );
  73.  
  74.     Begin { SetColor }
  75.       Port[$3C8] := Color;
  76.       Port[$3C9] := Red;
  77.       Port[$3C9] := Green;
  78.       Port[$3C9] := Blue;
  79.     End;  { SetColor }
  80.  
  81.  
  82.   Procedure DispVert ( Var CurrLine : Integer );
  83.  
  84.     Var Letter : OneChar;
  85.         VertLine,
  86.         Count  : Integer;
  87.  
  88.     Begin { DispVert }
  89.       Letter := CharSet[Ord(DispStr[(CurrLine Div 8)+1])+1];
  90.       VertLine := (CurrLine-1) Mod 8;
  91.       For Count := 1 To 8 Do
  92.         If Letter[Count] And ($80 Shr VertLine) = 0
  93.           Then Mem[VGA_Segment:185*320+(Count-1)*320+319] := 0
  94.           Else Mem[VGa_Segment:185*320+(Count-1)*320+319] := 181;
  95.     End;  { DispVert }
  96.  
  97.  
  98.   Procedure CalcLocs;
  99.  
  100.     Var Count : Integer;
  101.  
  102.     Begin { CalcLocs }
  103.       For Count := 1 To NumCycles Do
  104.         Locs[Count] := Round(Radius*Sin((2*Pi/NumCycles)*Count))+Radius+1;
  105.     End;  { CalcLocs }
  106.  
  107.  
  108.     Procedure DoCycle;
  109.  
  110.       Label Wait,Retr,BarLoop,PrevIsLast,Continue1,Continue2,Rep1,Rep2;
  111.  
  112.       Begin { DoCycle }
  113.         Asm
  114.  
  115.           MOV   DX,3DAh
  116. Wait:     IN    AL,DX
  117.           TEST  AL,08h
  118.           JZ    Wait
  119. Retr:     IN    AL,DX
  120.           TEST  AL,08h
  121.           JNZ   Retr
  122.  
  123. { Do Bars... }
  124.  
  125.            MOV   BX,0
  126. BarLoop:
  127.            PUSH  BX
  128.            MOV   AX,Word Ptr BarLocs[BX]
  129.            MOV   BX,AX
  130.            DEC   BX
  131.            SHL   BX,1
  132.            MOV   AX,Word Ptr Locs[BX]
  133.            PUSH  AX
  134.            CMP   BX,0
  135.            JE    PrevIsLast
  136.            DEC   BX
  137.            DEC   BX
  138.            MOV   AX,Word Ptr Locs[BX]
  139.            JMP   Continue1
  140.  
  141. PrevIsLast:
  142.            MOV   AX,Word Ptr Locs[(NumCycles-1)*2]
  143.  
  144. Continue1:
  145.            MOV   DX,03C8h
  146.            OUT   DX,AL
  147.            INC   DX
  148.            MOV   CX,15*3
  149.            MOV   AL,0
  150. Rep1:
  151.            OUT   DX,AL
  152.            LOOP  Rep1
  153.  
  154.            DEC   DX
  155.            POP   AX
  156.            OUT   DX,AL
  157.            INC   DX
  158.            MOV   CX,15*3
  159.            XOR   BX,BX
  160. Rep2:
  161.            MOV   AL,Byte Ptr Colors[BX]
  162.            OUT   DX,AL
  163.            INC   BX
  164.            LOOP  Rep2
  165.  
  166.            POP   BX
  167.            INC   Word Ptr BarLocs[BX]
  168.            CMP   Word Ptr BarLocs[BX],NumCycles
  169.            JNG   Continue2
  170.  
  171.            Mov   Word Ptr BarLocs[BX],1
  172. Continue2:
  173.            INC   BX
  174.            INC   BX
  175.            CMP   BX,8
  176.            JNE   BarLoop
  177.  
  178.         End;
  179.       End;  { DoCycle }
  180.  
  181.  
  182.   Var CurrVert,
  183.       Count     : Integer;
  184.       Key       : Char;
  185.       MemPos    : Word;
  186.  
  187.   Begin { PaletteTricks }
  188.  
  189.     VideoMode($13);
  190.     Port[$3C8] := 1;
  191.     For Count := 1 To 180 Do
  192.       SetColor(Count,0,0,0);
  193.     MemPos := 0;
  194.     For Count := 1 To 180 Do
  195.       Begin
  196.         FillChar(Mem[VGA_Segment:MemPos],320,Chr(Count));
  197.         MemPos := MemPos + 320;
  198.       End;
  199.     SetColor(181,63,63,0);
  200.     CalcLocs;
  201.     For Count := 1 To 4 Do
  202.       BarLocs[Count] := Count*10;
  203.  
  204.     GetChars;
  205.     CurrVert := 1;
  206.     Repeat
  207.       DoCycle;
  208.       For Count := 1 To 8 Do
  209.         Move(Mem[VGA_Segment:185*320+(Count-1)*320+1],
  210.              Mem[VGA_Segment:185*320+(Count-1)*320],319);
  211.       DispVert(CurrVert);
  212.       Inc(CurrVert);
  213.       If CurrVert > Length(DispStr) * 8
  214.         Then CurrVert := 1;
  215.  
  216.     Until Keypressed;
  217.     Key := ReadKey;
  218.     VideoMode(3);
  219.   End.  { PaletteTricks }
  220.